//change to ASCII 

import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args){
		try{
			File file=new File(args[0]);
			BufferedInputStream bufferedinputstream=new BufferedInputStream(new FileInputStream(file));
			ByteArrayOutputStream bytearrayoutputstream=new ByteArrayOutputStream();

			byte[] bytes=new byte[1];
			while(bufferedinputstream.read(bytes)!=-1){
				bytearrayoutputstream.write(bytes);
	
			}			
			bytearrayoutputstream.close();

			bufferedinputstream.close();


			bytes=bytearrayoutputstream.toByteArray();
			for(int i=0;i<bytes.length;i++){
				System.out.println((char)bytes[i]);
			}	
			System.out.println();

			Scanner scanner=new Scanner(System.in);
			System.out.print("input index you want to modify:");
			int pos=scanner.nextInt();
			System.out.print("input the char you want to modify:");
			bytes[pos-1]=(byte)scanner.next().charAt(0);
			ByteArrayInputStream bytearrayinputstream=new ByteArrayInputStream(bytes);
			BufferedOutputStream bufferedoutputstream=new BufferedOutputStream(new FileOutputStream(file));
			byte[] temp=new byte[1];
			while(bytearrayinputstream.read(temp)!=-1){
				bufferedoutputstream.write(temp);
			}
			bytearrayinputstream.close();
			bufferedoutputstream.flush();			
			bufferedoutputstream.close();

		}
		catch(ArrayIndexOutOfBoundsException e){
			e.printStackTrace();
		}
		catch(IOException e){
			e.printStackTrace();
		}
	}
}